// latest threads by rouad , edit by YahoOoH
//if (!isset($action) or $action == "getactive") {
// active topics
$result = $DB_site->query("select threadid,forumid,title,postusername,lastposter,replycount,views from thread WHERE visible order by lastpost desc limit 20");


if (!mysql_num_rows($result)) {
eval("\$threadbits = \"".fetch_template('home_nothreads')."\";");

}
if (mysql_num_rows($result)) {
while ($latest_array = $DB_site->fetch_array($result)) {
$result_thread_text = $DB_site->query("select postid,dateline,pagetext from post where threadid='$latest_array[threadid]' order by dateline desc limit 1");
$result_thread_array = $DB_site->fetch_array($result_thread_text);

$title = $latest_array['title'];
$forumid = $latest_array["forumid"];
$startedby = $latest_array['postusername'];
$numreplies = $latest_array['replycount'];
$lastposter = $latest_array['lastposter'];
$mpostid= $result_thread_array['postid'];
$numviews = $latest_array['views'];
$excludeforums = "2";
$atpostdate=vbdate($dateformat,$result_thread_array[dateline]);
$atposttime=vbdate($timeformat,$result_thread_array[dateline]);
$excludeforums = "2"; // if you want to exclude a forum, put it's ID here. more than one, seperate them with commas, NO SPACES! e.g. 1,2,3,4

$gothreadid = $latest_array["threadid"];
if (($counter++ % 2) != 0) {
$threadbg="#E9EBE9";
} else {
$threadbg="#FFFDE5";
}

eval("\$threadbits .= \"".fetch_template('home_threadbits')."\";");
}
}
//}

if ($action == "getnew") {
// new posts by rouad , edit by YahoOoH
$result = $DB_site->query("select threadid,forumid,title,postusername,lastposter,views from thread WHERE visible AND thread.lastpost>=".$bbuserinfo[lastvisit]." AND thread.open<>10 order by lastpost desc limit 5");

if (!mysql_num_rows($result)) {
eval("\$threadbits = \"".fetch_template('home_nothreads')."\";");
} else {
while ($latest_array = $DB_site->fetch_array($result)) {
$result_thread_text = $DB_site->query("select postid,dateline,pagetext from post where threadid='$latest_array[threadid]' order by dateline desc limit 1");
$result_thread_array = $DB_site->fetch_array($result_thread_text);

$title = $latest_array["title"];
$forumid = $latest_array["forumid"];
$startedby = $latest_array["postusername"];
$lastposter = $latest_array["lastposter"];
$mpostid= $result_thread_array["postid"];
$numviews = $latest_array["views"];
$excludeforums = "2";
$atpostdate=vbdate($dateformat,$result_thread_array[dateline]);
$atposttime=vbdate($timeformat,$result_thread_array[dateline]);
$excludeforums = "2"; // if you want to exclude a forum, put it's ID here. more than one, seperate them with commas, NO SPACES! e.g. 1,2,3,4

$gothreadid = $latest_array["threadid"];
if (($counter++ % 2) != 0) {
$threadbg="#E9EBE9";
} else {
$threadbg="#FFFDE5";
}
eval("\$threadbits .= \"".fetch_template('home_threadbits')."\";");
}
}
}

eval("\$threads = \"".fetch_template('home_threads')."\";");
eval('print_output("' . fetch_template('FORUMHOME') . '");');
